//
//  YTHomeMidCell.m
//  CllForIOS
//
//  Created by qiyun on 2018/3/8.
//  Copyright © 2018年 aRui. All rights reserved.
//

#import "YTHomeMidView.h"

@interface YTHomeMidView ()

@property (nonatomic, strong) UIImageView *leftBg;
@property (nonatomic, strong) UIImageView *rightBg;

@property (nonatomic, strong) UIImageView *leftIma;
@property (nonatomic, strong) UIImageView *rightIma;

@property (nonatomic, strong) UILabel *leftL;
@property (nonatomic, strong) UILabel * rightL;
//
@property (nonatomic, strong) UILabel * textLabel;
@property (nonatomic, strong) UIImageView *loveicon;


@end

@implementation YTHomeMidView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]){
        [self makeUI];
    }
    return self;
}

- (void)makeUI{
   //
    UIImageView*loveicon=[[UIImageView alloc]init];
    loveicon.image=IMAGE(@"smallicon");
    [self addSubview:loveicon];
    self.loveicon = loveicon;
    //
    UILabel*textLabel=[[UILabel alloc]init];
    textLabel.text=@"更多资讯";
    textLabel.font=KFONT_medium(13);
    textLabel.textColor=RGBA(144, 144, 144);
    [self addSubview:textLabel];
    self.textLabel = textLabel;
    

    UIImageView *leftBg = [[UIImageView alloc]init];
    [self  addSubview:leftBg];
    leftBg.userInteractionEnabled=YES;
    UITapGestureRecognizer *lefttapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickleftImage:)];
    [leftBg addGestureRecognizer:lefttapGesture];
    self.leftBg = leftBg;
    self.leftBg.tag=1;
    
    UIImageView *rightBg = [[UIImageView alloc]init];
    [self addSubview:rightBg];
    rightBg.userInteractionEnabled=YES;
    UITapGestureRecognizer *righttapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickrightImage:)];
    [rightBg addGestureRecognizer:righttapGesture];
    self.rightBg = rightBg;
    self.rightBg.tag=2;
    //
    UIImageView *leftIma = [[UIImageView alloc]initWithImage:IMAGE(@"home_football")];
    [self.leftBg addSubview:leftIma];
    self.leftIma = leftIma;
    UIImageView *rightIma = [[UIImageView alloc]initWithImage:IMAGE(@"home_basketball")];
    [self.rightBg addSubview:rightIma];
    self.rightIma = rightIma;
    //
    UILabel *leftL =[[UILabel alloc]init];
    leftL.textColor=RGBa(0, 0, 0, 0.78);
    leftL.font=[UIFont fontWithName:@"PingFangSC-Medium" size:11];
    leftL.text=@"焦点赛事";
    [self.leftBg addSubview:leftL];
    self.leftL = leftL;
    
    UILabel *rightL =[[UILabel alloc]init];
    rightL.textColor=RGBa(0, 0, 0, 0.78);
    rightL.font= [UIFont fontWithName:@"PingFangSC-Medium" size:11];
   
    rightL.text=@"比分直播";
    [self.rightBg addSubview:rightL];
    self.rightL = rightL;
    
}
-(void)layoutSubviews{
    [super layoutSubviews];
    
    self.loveicon.frame=CGRectMake(12, 12, 16, 14);
    self.textLabel.frame=CGRectMake(CGRectGetMaxX(self.loveicon.frame)+7, 12, 100, 13);
    
    self.leftBg.frame=CGRectMake(12, 50, 178, 65);
    self.rightBg.frame=CGRectMake(CGRectGetMaxX( self.leftBg.frame)+10, 50,178,65);
    
    self.leftIma.frame=CGRectMake(12, 8, AfW(50), AfW(50));
    self.rightIma.frame=CGRectMake(12, 8, AfW(50), AfW(50));
    
    self.leftL.frame=CGRectMake(CGRectGetMaxX( self.leftIma.frame)+AfW(42), 26, AfW(82), AfW(13));
    self.rightL.frame=CGRectMake(CGRectGetMaxX( self.rightIma.frame)+AfW(42), 26, AfW(82), AfW(13));
}
-(void)clickleftImage:(UIGestureRecognizer *)gestureRecognizer{
    if ([self.Delegate respondsToSelector:@selector(pressTheimageWithTag:)]) {
        [self.Delegate pressTheimageWithTag:gestureRecognizer.view.tag];
    }
}
-(void)clickrightImage:(UIGestureRecognizer *)gestureRecognizer{
    if ([self.Delegate respondsToSelector:@selector(pressTheimageWithTag:)]) {
        [self.Delegate pressTheimageWithTag:gestureRecognizer.view.tag];
    }
}

@end
